package licode.unisop.log.client.feign.impl;

import licode.unisop.client.api.auth.AuthTokenShim;
import licode.unisop.log.client.api.LoginLogApi;
import licode.unisop.log.client.dto.LoginLogDTO;
import licode.unisop.log.client.feign.LogOpFeign;
import licode.unisop.log.client.feign.LogQueryFeign;
import licode.unisop.log.client.req.LoginLogIn;
import licode.unisop.unilite.dp.PageData;
import licode.unisop.unilite.utils.TryMethodCall;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 日志查询
 *
 * @author licode
 */
@Component
public class LoginLogApiFeign implements LoginLogApi {
    @Resource
    private LogQueryFeign logQueryFeign;

    @Resource
    private LogOpFeign logOpFeign;

    @Resource
    private AuthTokenShim authTokenShim;

    @Override
    public void save(LoginLogDTO loginLogDto) {
        logOpFeign.saveLogin(authTokenShim.platformToken(""), loginLogDto);
    }

    @Override
    public void saveList(List<LoginLogDTO> loginLogs) {

    }

    @Override
    public PageData<LoginLogDTO> query(LoginLogIn loginLogIn) {
        return TryMethodCall.execFeign(()->
                logQueryFeign.loginList(authTokenShim.platformToken(""), loginLogIn));
    }
}
